//
//  UIImage+KY.m
//  KYCheckInSDK
//
//  Created by 罗新 on 2017/10/20.
//  Copyright © 2017年 KuaiYan  Co.,LTD. All rights reserved.
//

#import "UIImage+KY.h"

@implementation UIImage (KY)
+ (instancetype)ky_imageNamed:(NSString *)name{
    NSBundle *bundle = [NSBundle bundleWithPath:[[NSBundle mainBundle] pathForResource:@"Frameworks/KYSignSDK.framework" ofType:nil]];
    NSString *path = [bundle pathForResource:@"kyResource" ofType:@"bundle"];
    NSString * imagePath = nil;
    if ([name hasSuffix:@".png"]) {
        imagePath = [path stringByAppendingPathComponent:name];
    }else{
        imagePath = [path stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.png",name]];
    }
    return [UIImage imageWithContentsOfFile:imagePath];
}
+ (instancetype)ky_imageWithColor:(UIColor *)color{
    CGRect rect = CGRectMake(0.0f, 0.0f, 1.0f, 1.0f);
    UIGraphicsBeginImageContext(rect.size);
    CGContextRef context = UIGraphicsGetCurrentContext();
    CGContextSetFillColorWithColor(context, [color CGColor]);
    CGContextFillRect(context, rect);
    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();    UIGraphicsEndImageContext();
    return image;
}
@end
